package tests.page;

import common.Utils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description: 注册页面
 * User: Spider-Man
 * Date: 2025-09-21
 * Time: 13:39
 */
public class RegisterPage extends Utils{
    public static final String url = "http://43.143.179.59:8080/register.html";
    /**
     * 注册管理员用户
     */
    public void registerAdminPage() throws IOException {
        driver.get(url);
        WebElement element = driver.findElement(By.cssSelector("body > div > h2"));
        String expect = element.getText();
        assert expect.equals("填写注册信息"):"填写注册信息未加载!!!";
        //姓名相关元素
        element = driver.findElement(By.cssSelector("#registerForm > div:nth-child(1) > label"));
        expect = element.getText();
        assert expect.equals("姓名"):"姓名元素未加载!!!";
        expect = driver.findElement(By.cssSelector("#name")).getAttribute("placeholder");
        assert expect.equals("请输入姓名");
        //邮箱相关元素
        element = driver.findElement(By.cssSelector("#registerForm > div:nth-child(2) > label"));
        expect = element.getText();
        assert expect.equals("邮箱"):"邮箱元素未加载!!!";
        expect = driver.findElement(By.cssSelector("#mail")).getAttribute("placeholder");
        assert expect.equals("请输入邮箱");
        //手机号相关元素
        element = driver.findElement(By.cssSelector("#registerForm > div:nth-child(3) > label"));
        expect = element.getText();
        assert expect.equals("手机号"):"手机号元素未加载!!!";
        expect = driver.findElement(By.cssSelector("#phoneNumber")).getAttribute("placeholder");
        assert expect.equals("请输入手机号");
        //密码相关元素
        element = driver.findElement(By.cssSelector("#registerForm > div:nth-child(4) > label"));
        expect = element.getText();
        assert expect.equals("密码"):"密码元素未加载!!!";
        expect = driver.findElement(By.cssSelector("#password")).getAttribute("placeholder");
        assert expect.equals("请输入密码"):"请输入密码元素未加载";

        //注册属性值
        element = driver.findElement(By.cssSelector("#registerForm > button"));
        expect = element.getText();
        assert expect.equals("注册") : "注册元素未加载!!!";
        getScreenShot(getClass().getName());
    }
}
